<template>
  <a-card :bordered="false">

    <!-- 查询区域 -->
    <div class="table-page-search-wrapper search-box-cuesList">
      <a-form layout="inline" @keyup.enter.native="searchQuery">
        <a-row :gutter="24">
          <a-col :xl="6" :lg="7" :md="8" :sm="24">
            <a-form-item label="协议类型">
              <j-dict-select-tag placeholder="请输入协议类型" v-model="queryParam.protocolType" class="select-box"
                                 dict-code="sys_user_protocol_protocol_type"></j-dict-select-tag>
            </a-form-item>
          </a-col>
          <a-col :xl="6" :lg="7" :md="8" :sm="24">
            <span style="float: left;overflow: hidden;" class="table-page-search-submitButtons">
              <a-button type="primary" @click="searchQuery" icon="search" title="搜索" shape="circle"></a-button>
              <a-button type="primary" @click="searchReset" icon="reload" style="margin-left: 8px" title="重置"
                        shape="circle"></a-button>
            </span>
          </a-col>
        </a-row>
      </a-form>
    </div>

    <!-- 操作按钮区域 -->

    <div class="ant-alert ant-alert-info" style="display:flex;padding-left: 10px; align-items: center;">
      <div class="table-operator" style="flex:1;text-align: left;margin-bottom:0">
        <a-button @click="handleAdd" type="primary" icon="plus">新增</a-button>
      </div>
      <div>
        <i class="anticon anticon-info-circle ant-alert-icon"></i> 已选择 <a style="font-weight: 600">{{
        selectedRowKeys.length }}</a>项
        <a style="margin-left: 24px" @click="onClearSelected">清空</a>
      </div>
    </div>

    <!-- table区域-begin -->
    <div>
      <a-table
        ref="table"
        size="middle"
        bordered
        rowKey="id"
        :columns="columns"
        :dataSource="dataSource"
        :pagination="ipagination"
        :loading="loading"
        :rowSelection="{selectedRowKeys: selectedRowKeys, onChange: onSelectChange}"
        @change="handleTableChange">

        <span slot="action" slot-scope="text, record">
          <a @click="handleEdit(record)" title="编辑"><a-icon type="edit" theme="filled"/></a>

          <a-divider type="vertical"/>

          <a-popconfirm title="确定删除吗?" @confirm="() => handleDelete(record.id)">
            <a title="删除"><a-icon type="delete" theme="filled" style="color:#ed7770"/></a>
          </a-popconfirm>
        </span>
        <span class="protocolContent_li" slot="protocolContent" slot-scope="text, record">
          <span v-html="record.protocolContent"></span>
        </span>
      </a-table>
    </div>
    <!-- table区域-end -->

    <!-- 表单区域 -->
    <sysUserProtocol-modal ref="modalForm" @ok="modalFormOk"></sysUserProtocol-modal>
  </a-card>
</template>

<script>
  import SysUserProtocolModal from './modules/SysUserProtocolModal'
  import {JeecgListMixin} from '@/mixins/JeecgListMixin'

  export default {
    name: "SysUserProtocolList",
    mixins: [JeecgListMixin],
    components: {
      SysUserProtocolModal
    },
    data() {
      return {
        description: '系统用户协议管理页面',
        // 表头
        columns: [
          {
            title: '#',
            dataIndex: '',
            key: 'rowIndex',
            width: 60,
            align: "center",
            customRender: function (t, r, index) {
              return parseInt(index) + 1;
            }
          },
          {
            title: '协议类型',
            align: "center",
            dataIndex: 'protocolType_dictText'
          },
          {
            title: '备注',
            align: "center",
            dataIndex: 'remark'
          },
          {
            title: '操作',
            dataIndex: 'action',
            align: "center",
            scopedSlots: {customRender: 'action'},
          }
        ],
        url: {
          list: "/system/sysUserProtocol/list",
          delete: "/system/sysUserProtocol/delete",
          deleteBatch: "/system/sysUserProtocol/deleteBatch",
          exportXlsUrl: "system/sysUserProtocol/exportXls",
          importExcelUrl: "system/sysUserProtocol/importExcel",
        },
      }
    },
    computed: {
      importExcelUrl: function () {
        return `${window._CONFIG['domianURL']}/${this.url.importExcelUrl}`;
      }
    },
    methods: {}
  }
</script>
<style scoped>
  @import '~@assets/less/common.less'
</style>